using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using SiteManager;

public partial class Doctor_CustomerService : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ListItem li;
            li = new ListItem("-- Select --", "");
            li.Selected = true;

            for (int i = DateTime.Now.Year - 60; i <= DateTime.Now.Year; i++)
            { ddlGradYear.Items.Add(new ListItem(i.ToString(), i.ToString())); }
            ddlGradYear.Items.Add(li);

            Manager mgr = new Manager(true,"ConnectionString");

            mgr.BindList("SELECT ID,NAME FROM TBL_SPECIALITY ORDER BY [NAME]", "NAME", "ID", ddlSpecialty, "");
            ddlSpecialty.Items.Add(li);
            mgr.BindList("SELECT ID,NAME FROM TBL_SECONDARYSPECIALITY ORDER BY [NAME]", "NAME", "ID", ddlSubspecialty, "");
            ddlSubspecialty.Items.Add(li);
            mgr.BindList("SELECT CITYID,NAME FROM TBL_CITY ORDER BY [NAME]", "NAME", "CITYID", ddlCity, "");
            ddlCity.Items.Add(li);
            mgr.BindList("SELECT STATEID,NAME FROM TBL_STATES ORDER BY [NAME]", "NAME", "STATEID", ddlState, "");
            ddlState.Items.Add(li);
            mgr = null;
            lnkMedSch.Attributes.Add("onclick", "popUp(2,'" + hdnMedSch.ClientID + "','" + lblMedSch.ClientID + "')");
        }
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Validation vl = new Validation();
        vl.AddValidation(hdnMedSch.Value, Validation.ValidationCommand.required, "Please select Medical School","");
        if (!vl.CheckError())
        {
            trErr.Visible = true;
            blstErrors.DataSource = vl.ErrList;
            blstErrors.DataBind();
            return;
        }
        else
        {
            StringBuilder str = new StringBuilder(string.Empty);
            str.Append("First Name: ");
            str.Append(txtFirstName.Text);
            str.Append("<br>");
            str.Append("Last Name ");
            str.Append(txtLastName.Text);
            str.Append("<br>");
            str.Append("Specialty ");
            str.Append(ddlSpecialty.SelectedItem.Text);
            str.Append("<br>");
            str.Append("Subspecialty ");
            str.Append(ddlSubspecialty.SelectedItem.Text);
            str.Append("<br>");
            str.Append("Address ");
            str.Append(txtAddress.Text);
            str.Append("<br>");
            str.Append("City ");
            str.Append(ddlCity.SelectedItem.Text);
            str.Append("<br>");
            str.Append("State ");
            str.Append(ddlState.SelectedItem.Text);
            str.Append("<br>");
            str.Append("Zip ");
            str.Append(txtZip.Text); 
            str.Append("<br>");
            str.Append("Phone Number ");
            str.Append(txtPhoneNumber.Text);
            str.Append("<br>");
            str.Append("Email ");
            str.Append(txtEMail.Text);
            str.Append("<br>");
            str.Append("Medical School ");
            str.Append(hdnMedSch.Value);
            str.Append("<br>");
            str.Append("Medical School Graduation Year ");
            str.Append(ddlGradYear.SelectedItem.Text);
            str.Append("<br>");
            str.Append("UPIN ");
            str.Append(txtUPIN.Text);
            str.Append("<br>");
            str.Append("Reason ");
            str.Append(txtReason.Text);
            str.Append("<hr noshade>");

            Manager mgr = new Manager(true,"ConnectionString");
            mgr.sendMail(str.ToString(), "synapsetesting@gmail.com", txtFirstName.Text, "Customer Care", txtEMail.Text, "");
            mgr = null;
            str = null;

            lblMsg.Text = "We have received your information and will get back to you soon.";
        }
    }
}
